package nl.zoidberg.calculon.engine;

import java.util.HashMap;
import java.util.Map;


public class RookMoveGenerator extends StraightMoveGenerator {

	public static int[][] DIRECTIONS = new int[][] {
		{ 1, 0 },
		{ 0, 1 },
		{ -1, 0 },
		{ 0, -1 },
	};

	@Override
	public int[][] getDirections() {
		return DIRECTIONS;
	}

	@Override
	public Map<String, Board> generateMoves(Board board) {
		Map<String, Board> rv = new HashMap<String, Board>();
		
		BitBoard bitBoard = board.getBitBoard();
		long pieces = bitBoard.getBitmapColor(board.getPlayer()) & bitBoard.getBitmapRooks();
		while(pieces != 0) {
			long nextPiece = Long.highestOneBit(pieces);
			pieces ^= nextPiece;
			int[] coords = BitBoard.toCoords(nextPiece);
			rv.putAll(this.generateMoves(board, coords[0], coords[1]));
		}
		
		return rv;
	}
}